package com.ijunfu.spring.component_scan._04_component_index;

import com.ijunfu.spring.component_scan._04_component_index.config.AppConfiguration;
import com.ijunfu.spring.component_scan._04_component_index.service.RoleService;
import com.ijunfu.spring.component_scan._04_component_index.service.UserService;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 *
 * @Title  : 
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/11/5 14:03
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
@SpringBootApplication
public class ScanIndexMain {

    public static void main(String[] args) {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfiguration.class);

        System.out.println("==================================");
        RoleService roleService = context.getBean(RoleService.class);
        System.out.println(roleService);

        System.out.println("==================================");
        // 报错：不存在Bean
        UserService userService = context.getBean(UserService.class);
        System.out.println(userService);
    }
}
